package main
 
import (
	"bufio"
	"crypto/sha256"
	"encoding/hex"
	"fmt"
	"os"
	"strings"
	"sync"
)
 
func main() {
	target := "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8" // Target SHA256 hash
	dictionary := "dictionary.txt" // Dictionary file
 
	file, _ := os.Open(dictionary)
	defer file.Close()
 
	var wg sync.WaitGroup
 
	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		wg.Add(1)
		go func(word string) {
			defer wg.Done()
			hash := sha256.Sum256([]byte(word))
			hashString := hex.EncodeToString(hash[:])
			if hashString == target {
				fmt.Printf("Found! The word for hash '%s' is '%s'\n", target, word)
			}
		}(scanner.Text())
	}
 
	wg.Wait()
}